
import { Viewer, ScreenSpaceEventType } from 'cesium';
import { useCesiumGlobalStore } from "@/store/modules/cesiun-global"
import { setEventByHandler } from '@/utils';

export default class BaseLoader {
    //esc事件
    escEvent(e: KeyboardEvent) {
        const cesiumGlobalStore = useCesiumGlobalStore()
        const loader = cesiumGlobalStore.getLoader()
        if (e.key === 'Escape') {
            loader && loader.destroy()
        }
    }
    constructor(viewer: Viewer, options?: Record<string, any>) {
        this.initEscEvent();
    }

    /**
     * 监听esc事件
     */
    initEscEvent() {
        document.addEventListener('keydown', (e: KeyboardEvent) => this.escEvent(e));
    }

    /**
     * 移除监听esc事件
     */
    removeEscEvent() {
        document.removeEventListener('keydown', this.escEvent);
    }
}